
 use  "\connectfirst_scid_replication.dta" ,clear
 

 #delimit ;
macro define covars0 "lngdp internet_user  Coup election_total   pve   gee  v2mecrit "
;


/////////Constructing main independent variables////////////////////////////

// gen lnComm_gdp=ln(commaid/gdp +1)
// gen lnOther_gdp=ln(otheraid /gdp+1)
// gen lnwbcomm_gdp =ln(wbcommaid/gdp+1)
// gen lnwbother_gdp=ln(wbotheraid/gdp+1)
// gen lnuscomm_gdp =ln(uscommaid/gdp+1)
// gen lnusother_gdp=ln(usotheraid/gdp+1)
//
//
// foreach nvar of varlist lnComm_gdp- lnusother_gdp{
// by cowcode (year), sort: gen running_sum_var = sum(`nvar')
// by cowcode (year): gen running_count_var = sum(!missing(`nvar')) 
// by cowcode (year): gen `nvar'3= (running_sum_var - L5.running_sum_var)/(running_count_var-L5.running_count_var) if _n > 5
// by cowcode: replace `nvar'3 = running_sum_var/running_count_var if _n <= 3
// drop running_sum_var running_count_var
// }




//reversing DVs (from V-Dem) for easy interpretation//
//
// gen smgovshut=v2smgovshut*-1
// gen mecenefi=v2mecenefi*-1
// gen smregapp = v2smregapp*-1
// gen smgovsm=v2smgovsm*-1
// gen smgovsmcenprc=v2smgovsmcenprc*-1
// gen smgovsmalt=v2smgovsmalt*-1


//TABLE 1. Aid and the Erosion of Internet Freedom///
eststo clear
eststo: xtreg  f.smgovshut  lnComm_gdp3  lnOther_gdp3  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovshut  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovshut  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3  $covars0 democracy i.year if incgroup !=1, fe  vce(r)

eststo: xtreg  f.mecenefi  lnComm_gdp3  lnOther_gdp3  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.mecenefi  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.mecenefi lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0  democracy i.year if incgroup !=1, fe  vce(r)

eststo: xtreg  f.smregapp  lnComm_gdp3  lnOther_gdp3  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smregapp lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smregapp lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0 democracy   i.year if incgroup !=1, fe  vce(r)


		
		
esttab using "internetfreedom.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


//TABLE 2. Aid and the Erosion of Social Media Freedom///

eststo clear
eststo: xtreg  f.smgovsm  lnComm_gdp3  lnOther_gdp3  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsm  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.smgovsm lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0 democracy  i.year if incgroup !=1, fe  vce(r)


eststo: xtreg  f.smgovsmcenprc    lnComm_gdp3  lnOther_gdp3  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsmcenprc    lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.smgovsmcenprc  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0  democracy i.year if incgroup !=1, fe  vce(r)


eststo: xtreg  f.smgovsmalt   lnComm_gdp3  lnOther_gdp3  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsmalt  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.smgovsmalt  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0 democracy  i.year if incgroup !=1, fe  vce(r)



esttab using "smfreedom.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))
		

		
		
///Table 3. Internet and Social Media Freedom in Autocracies///

eststo clear
eststo: xtreg  f.smgovshut  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==0, fe  vce(r)
eststo: xtreg  f.mecenefi   lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==0, fe  vce(r)
eststo: xtreg  f.smregapp  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==0, fe  vce(r)
eststo: xtreg  f.smgovsm  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==0, fe  vce(r)
eststo: xtreg  f.smgovsmcenprc    lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==0, fe  vce(r)
eststo: xtreg  f.smgovsmalt  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==0, fe  vce(r)


esttab using "internetfreedom_autocracy.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))
		
		
		
		
///Table 4. Internet and Social Media Freedom in Democracies///
eststo clear
eststo: xtreg  f.smgovshut  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==1, fe  vce(r)
eststo: xtreg  f.mecenefi   lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==1, fe  vce(r)
eststo: xtreg  f.smregapp  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==1, fe  vce(r)
eststo: xtreg  f.smgovsm  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==1, fe  vce(r)
eststo: xtreg  f.smgovsmcenprc    lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==1, fe  vce(r)
eststo: xtreg  f.smgovsmalt  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==1, fe  vce(r)


esttab using "internetfreedom_democracy.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))



//Figure 4. The effect of Chinese communication aid on the erosion of internet and social media freedom//
use "aidproject_tsfill_23.dta", clear
sort cowcode year
by cowcode (year): egen first_non_zero_year = min(year) if commaid> 0
by cowcode: egen min_value =min(first_non_zero_year )
drop first_non_zero_year 
rename min_value first_year_aid
gen time_to_aid= year-first_year_aid 

eventdd smgovshut, hdfe absorb(i.year i.cowcode  ) timevar(time_to_aid) lags (4) leads (4) ci(rcap) cluster(cowcode) level(90) inrange ci_op(color(black)) coef_op(msymbol(S) color(black) msize(2.5pt)) noline graph_op(graphregion(fcolor(white)) title("Internet Shutdown" , size(medium) ) xtitle("")ytitle("Average treatment effect", height(5)) ylabel(, nogrid) xlabel(-4(1)4, nogrid) lwidth(thin) xline(-1, lcolor(gs6) lwidth(thin) lpattern(dash)) legend(off) ) 

graph save "internetshutdown", replace


eventdd mecenefi, hdfe absorb(i.year i.cowcode    ) timevar(time_to_aid) lags (4) leads (4) ci(rcap) cluster(cowcode) level(90) inrange ci_op(color(black)) coef_op(msymbol(S) color(black) msize(2.5pt)) noline graph_op(graphregion(fcolor(white)) title("Internet Censorship", size(medium)) ytitle("Average treatment effect", height(5)) ylabel(, nogrid) xtitle("") xlabel(-4(1)4, nogrid) lwidth(thin) xline(-1, lcolor(gs6) lwidth(thin) lpattern(dash)) legend(off) )
graph save "internetcensorship", replace

eventdd smregapp, hdfe absorb(i.year i.cowcode  ) timevar(time_to_aid) lags (4) leads (4) ci(rcap) cluster(cowcode) level(90) inrange ci_op(color(black)) coef_op(msymbol(S) color(black) msize(2.5pt)) noline graph_op(graphregion(fcolor(white)) title("Internet Gov Dominance", size(medium)) ytitle("Average treatment effect", height(5)) ylabel(, nogrid) xtitle("") xlabel(-4(1)4, nogrid) lwidth(thin) xline(-1, lcolor(gs6) lwidth(thin) lpattern(dash)) legend(off) )
graph save "internetgovdom", replace

eventdd smgovsm, hdfe absorb(i.year i.cowcode   ) timevar(time_to_aid) lags (4) leads (4) ci(rcap) cluster(cowcode) level(90) inrange ci_op(color(black)) coef_op(msymbol(S) color(black) msize(2.5pt)) noline graph_op(graphregion(fcolor(white)) title("Social Media Shutdown", size(medium)) ytitle("Average treatment effect", height(5)) ylabel(, nogrid) xtitle("") xlabel(-4(1)4, nogrid) lwidth(thin) xline(-1, lcolor(gs6) lwidth(thin) lpattern(dash)) legend(off) )
graph save "smshutdown", replace

eventdd smgovsmcenprc, hdfe absorb(i.year i.cowcode  ) timevar(time_to_aid) lags (4) leads (4) ci(rcap) cluster(cowcode) level(90) inrange ci_op(color(black)) coef_op(msymbol(S) color(black) msize(2.5pt)) noline graph_op(graphregion(fcolor(white))  title("Social Media Censorship", size(medium)) ytitle("Average treatment effect", height(5)) ylabel(, nogrid) xtitle("") xlabel(-4(1)4, nogrid) lwidth(thin) xline(-1, lcolor(gs6) lwidth(thin) lpattern(dash)) legend(off) )
graph save "smcensorship", replace

eventdd smgovsmalt, hdfe absorb(i.year i.cowcode   ) timevar(time_to_aid) lags (4) leads (4) ci(rcap) cluster(cowcode) level(90) inrange ci_op(color(black)) coef_op(msymbol(S) color(black) msize(2.5pt)) noline graph_op(graphregion(fcolor(white)) title("Social Media Gov Dominance", size(medium)) ytitle("Average treatment effect", height(5)) ylabel(, nogrid) xtitle("") xlabel(-4(1)4, nogrid) lwidth(thin) xline(-1, lcolor(gs6) lwidth(thin) lpattern(dash)) legend(off) )
graph save "smgovdom", replace

graph combine "internetshutdown" "internetcensorship" "internetgovdom" "smshutdown" "smcensorship" "smgovdom"




		
//Summary Statistics//

*====Table A2. Summary Statistics=========*
sutex2  smgovshut mecenefi smregapp smgovsm smgovsmcenprc smgovsmalt lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 lngdp internet_user  Coup election_total   pve   gee  v2mecrit democracy polity , minmax varlab

asdoc sum smgovshut mecenefi smregapp smgovsm smgovsmcenprc smgovsmalt lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 lngdp internet_user  Coup election_total   pve   gee  v2mecrit democracy polity, stat(N mean sd min max)

///Table A3 and A4 are the same as Table 1 and Table 2, with coefficients for controls reported///
		
///Table A5. Aid and Internet Freedom (with Polity Score)///
eststo clear
eststo: xtreg  f.smgovshut  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0    polity i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.mecenefi   lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   polity  i.year if incgroup !=1 , fe  vce(r)
eststo: xtreg  f.smregapp  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   polity  i.year if incgroup !=1 , fe  vce(r)
eststo: xtreg  f.smgovsm  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0    polity i.year if incgroup !=1 , fe  vce(r)
eststo: xtreg  f.smgovsmcenprc    lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0  polity   i.year if incgroup !=1 , fe  vce(r)
eststo: xtreg  f.smgovsmalt  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   polity   i.year if incgroup !=1 , fe  vce(r)

esttab using "internetfreedom_polity.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))

///A6. Models without year fixed effects///

eststo clear
eststo: xtreg  f.smgovshut  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   democracy  year if incgroup !=1 , fe  vce(r)
eststo: xtreg  f.mecenefi  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   democracy  year if incgroup !=1 , fe  vce(r)
eststo: xtreg  f.smregapp  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   democracy  year if incgroup !=1 , fe  vce(r)
eststo: xtreg  f.smgovsm  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   democracy  year if incgroup !=1 , fe  vce(r)
eststo: xtreg  f.smgovsmcenprc  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   democracy  year if incgroup !=1 , fe  vce(r)
eststo: xtreg  f.smgovsmalt  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   democracy  year if incgroup !=1 , fe  vce(r)

esttab using "noef.rtf", label   /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))





///A7. Measures of 5 year avg (Internet)///

eststo clear
eststo: xtreg  f.smgovshut  lnComm_gdp5 lnOther_gdp5   i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovshut  lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovshut  lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0 democracy  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.mecenefi  lnComm_gdp5 lnOther_gdp5    i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.mecenefi  lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5   i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.mecenefi  lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5  $covars0 democracy i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smregapp lnComm_gdp5 lnOther_gdp5     i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smregapp lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smregapp lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5  $covars0 democracy  i.year if incgroup !=1, fe  vce(r)

esttab using "fiveyravg_allmodel_internet.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))

///A8. Measures of 5 year avg (Social Media)///
eststo clear
eststo: xtreg  f.smgovsm lnComm_gdp5 lnOther_gdp5  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsm lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5   i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsm lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0 democracy i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsmcenprc lnComm_gdp5 lnOther_gdp5  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsmcenprc lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5   i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsmcenprc lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0 democracy i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsmalt lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5   i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsmalt lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5   i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsmalt lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0  democracy i.year if incgroup !=1, fe  vce(r)


esttab using "fiveyravg_allmodel_sm.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))



///A9. Measures of 5 year avg (Autocracy)///
eststo clear


eststo:xtreg  f.smgovshut  lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0 democracy i.year if incgroup !=1&democracy==0, fe  vce(r)
eststo:xtreg  f.mecenefi  lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0 democracy i.year if incgroup !=1&democracy==0, fe  vce(r)
eststo:xtreg  f.smregapp lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0 democracy i.year if incgroup !=1&democracy==0, fe  vce(r)
eststo:xtreg  f.smgovsm lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0 democracy i.year if incgroup !=1&democracy==0, fe  vce(r)
eststo:xtreg  f.smgovsmcenprc lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0 democracy i.year if incgroup !=1&democracy==0, fe  vce(r)
eststo:xtreg  f.smgovsmalt lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0  i.year if incgroup !=1&democracy==0, fe  vce(r)


esttab using "fiveyravg_autocracy.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


///A10. Measures of 5 year avg (Democracies)///
eststo clear
eststo:xtreg  f.smgovshut  lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0 democracy i.year if incgroup !=1&democracy==1, fe  vce(r)
eststo:xtreg  f.mecenefi  lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0 democracy i.year if incgroup !=1&democracy==1, fe  vce(r)
eststo:xtreg  f.smregapp lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0 democracy i.year if incgroup !=1&democracy==1, fe  vce(r)
eststo:xtreg  f.smgovsm lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0 democracy i.year if incgroup !=1&democracy==1, fe  vce(r)
eststo:xtreg  f.smgovsmcenprc lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0 democracy i.year if incgroup !=1&democracy==1, fe  vce(r)
eststo:xtreg  f.smgovsmalt lnComm_gdp5 lnOther_gdp5 lnwbcomm_gdp5 lnwbother_gdp5 lnuscomm_gdp5 lnusother_gdp5 $covars0  i.year if incgroup !=1&democracy==1, fe  vce(r)
esttab using "fiveyravg_democracy.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))

///A11. Aid and Internet Freedom (Huawei excluded)/// 

eststo clear
eststo: xtreg  f.smgovshut  lnComm_gdp_nhw3  lnOther_gdp3  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovshut  lnComm_gdp_nhw3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.smgovshut  lnComm_gdp_nhw3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0 democracy i.year if incgroup !=1, fe  vce(r)


eststo: xtreg  f.mecenefi  lnComm_gdp_nhw3  lnOther_gdp3  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.mecenefi  lnComm_gdp_nhw3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.mecenefi lnComm_gdp_nhw3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0  democracy i.year if incgroup !=1, fe  vce(r)


//
eststo: xtreg  f.v2smregapp  lnComm_gdp_nhw3  lnOther_gdp3  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.v2smregapp lnComm_gdp_nhw3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.v2smregapp lnComm_gdp_nhw3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0 democracy  i.year if incgroup !=1, fe  vce(r)

esttab using "internetfreedom_nhw.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp_nhw3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))



///A12. Aid and Social Media Freedom (Huawei excluded)
eststo clear
eststo: xtreg  f.v2smgovsm  lnComm_gdp_nhw3   lnOther_gdp3  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.v2smgovsm  lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.v2smgovsm lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0 democracy i.year if incgroup !=1, fe  vce(r)


eststo: xtreg  f.v2smgovsmcenprc    lnComm_gdp_nhw3  lnOther_gdp3  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.v2smgovsmcenprc    lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.v2smgovsmcenprc  lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0  democracy i.year if incgroup !=1, fe  vce(r)


eststo: xtreg  f.v2smgovsmalt   lnComm_gdp_nhw3   lnOther_gdp3  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.v2smgovsmalt  lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.v2smgovsmalt lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0 democracy  i.year if incgroup !=1, fe  vce(r)

esttab using "smfreedom_nhw.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp_nhw3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))




//A13. Internet and Social Media Freedom in Autocracies (Huawei excluded)



eststo clear
eststo: xtreg  f.v2smgovshut  lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==0, fe  vce(r)
eststo: xtreg  f.v2mecenefi   lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==0, fe  vce(r)
eststo: xtreg  f.v2smregapp  lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==0, fe  vce(r)
eststo: xtreg  f.v2smgovsm  lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==0, fe  vce(r)
eststo: xtreg  f.v2smgovsmcenprc    lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==0, fe  vce(r)
eststo: xtreg  f.v2smgovsmalt  lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==0, fe  vce(r)




esttab using "autocracy_nhw.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp_nhw3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))

		
		
///TA14.  Internet and Social Media Freedom in Democracies (Huawei excluded)///
eststo clear
eststo: xtreg  f.v2smgovshut lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==1, fe  vce(r)
eststo: xtreg  f.v2mecenefi  lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==1, fe  vce(r)
eststo: xtreg  f.v2smregapp lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==1, fe  vce(r)
eststo: xtreg  f.v2smgovsm  lnComm_gdp_nhw3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==1, fe  vce(r)
eststo: xtreg  f.v2smgovsmcenprc    lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==1, fe  vce(r)
eststo: xtreg  f.v2smgovsmalt  lnComm_gdp_nhw3  lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0   i.year if incgroup !=1& democracy==1, fe  vce(r)



esttab using "democracy_nhw.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp_nhw3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


		
		
///COHORT FIXED EFFECT///


///3 categories (cohort effect)///

xtile cohort_smgovshut_3 = smgovshut, n(3)
xtile cohort_mecenefi = mecenefi, n(3)
xtile cohort_smregapp = smregapp, n(3)
xtile cohort_smgovsm = smgovsm, n(3)
xtile cohort_smgovsmcenprc= smgovsmcenprc,n(3)
xtile cohort_smgovsmalt = smgovsmalt, n(3)


eststo clear
eststo: xtreg  f.smgovshut  lnComm_gdp3 lnOther_gdp3    i.year i.cohort_smgovshut_3 if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.smgovshut  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year i.cohort_smgovshut_3 if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.smgovshut  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3  $covars0 democracy  i.year i.cohort_smgovshut_3 if incgroup !=1, fe  vce(r)/*shutdown*/

eststo: xtreg  f.mecenefi  lnComm_gdp3 lnOther_gdp3    i.year i.cohort_mecenefi if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.mecenefi  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3    i.year i.cohort_mecenefi if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.mecenefi  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3  $covars0  democracy i.year i.cohort_mecenefi if incgroup !=1, fe  vce(r)/*shutdown*/

eststo: xtreg  f.smregapp lnComm_gdp3 lnOther_gdp3   i.year i.cohort_smregapp  if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.smregapp lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.year i.cohort_smregapp if incgroup !=1, fe  vce(r)/*shutdown*/
eststo: xtreg  f.smregapp lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3  $covars0  democracy	i.year i.cohort_smregapp if incgroup !=1, fe  vce(r)/*shutdown*/

esttab using "fixed_cohort_IF.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp3 lnOther_gdp3 lnuscomm_gdp3 lnusother_gdp3 lnwbcomm_gdp3 lnwbother_gdp3  )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


eststo clear

eststo: xtreg  f.smgovsm lnComm_gdp3 lnOther_gdp3   i.cohort_smgovsm  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsm lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3    i.cohort_smgovsm  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsm lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0 democracy i.cohort_smgovsm  i.year if incgroup !=1, fe  vce(r)

eststo: xtreg  f.smgovsmcenprc  lnComm_gdp3 lnOther_gdp3  i.cohort_smgovsmcenprc i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsmcenprc  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.cohort_smgovsmcenprc i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsmcenprc  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0  democracy i.cohort_smgovsmcenprc i.year if incgroup !=1, fe  vce(r)

eststo: xtreg  f.smgovsmalt  lnComm_gdp3 lnOther_gdp3  i.cohort_smgovsmalt  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsmalt  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3   i.cohort_smgovsmalt  i.year if incgroup !=1, fe  vce(r)
eststo: xtreg  f.smgovsmalt  lnComm_gdp3 lnOther_gdp3 lnwbcomm_gdp3 lnwbother_gdp3 lnuscomm_gdp3 lnusother_gdp3 $covars0 democracy i.cohort_smgovsmalt  i.year if incgroup !=1, fe  vce(r)



esttab using "fixed_cohort_SMF.rtf", label drop( *year* )  /// 
nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01)  ///
order(lnComm_gdp3 lnOther_gdp3 lnuscomm_gdp3 lnusother_gdp3 lnwbcomm_gdp3 lnwbother_gdp3  )  /// 
compress nogaps  nobase  mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))




		
////A17: INTERNET PENETRATION AND CHINESE AID///
xtreg f.lnComm_gdp L.internet_user  i.year if incgroup!=1, fe vce(r)
xtreg f.lnComm_gdp L.internet_user  lngdppc urbanpop i.year if incgroup!=1, fe vce(r)
xtreg f.lnComm_gdp L.internet_user     lngdppc urbanpop democracy  pve v2mecrit i.year if incgroup!=1, fe vce(r)
xtreg f.lnComm_gdp L.internet_user     lngdppc urbanpop democracy  pve v2mecrit L.lnOther_gdp3 i.year if incgroup!=1, fe vce(r)


		






